﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace AutomatedTP
{
    /// <summary>
    /// Static class for storing paths to XML source documents.
    /// </summary>
    public static class global_var
    {
        public static XElement XML_module;        
        public static XElement testCase;

        /// <summary>
        /// Set path to XML test case document.
        /// </summary>
        /// <param name="name">The name.</param>
        internal static void set_testCase(string name)
        {
            string pathString = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), name);
            if (!System.IO.File.Exists(pathString))
            {
                string ex = "File " + pathString + " does not exist!";
                throw new FileNotFoundException(ex);
            }
            testCase = XElement.Load(pathString);
        }

        /// <summary>
        /// Set path to XML module document.
        /// </summary>
        /// <param name="module">The module.</param>
        /// <exception cref="System.IO.FileNotFoundException"></exception>
        internal static void set_XML_module(string module) 
        {

            string pathString = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), module + ".xml");
            if (!System.IO.File.Exists(pathString))
            {
                string ex = "File " + pathString + " does not exist!";
                throw new FileNotFoundException(ex);
            }
            XML_module = XElement.Load(pathString);
        }
    }
}
